<template>
  <div>
    <ul>
      <li>
        <router-link to="/Contacts/All_Contacts">All Contacts</router-link>
      </li>
      <li><router-link to="/Contacts/Alice">Alice</router-link></li>
      <li><router-link to="/Contacts/Bob">Bob</router-link></li>
    </ul>
    <button @click="clickFn">随机显示</button>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  methods: {
    clickFn() {
      let arr = ['/Contacts/All_Contacts', '/Contacts/Alice', '/Contacts/Bob']
      let path = arr[Math.floor(Math.random() * arr.length)]
      if (this.$route.path !== path) {
        this.$router.push(path)
      }
    }
  },
}
</script>

<style scoped>
.router-link-active {
  color: red;
}
</style>